package com.ruoyi.web.controller.me;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ProcessStopException;
import com.ruoyi.me.service.DifferentSolarModelService;
import com.ruoyi.me.service.SpatialIndexForecastService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * </p>
 *
 * @author liuhl
 * @since 2024-06-15
 */

@RestController
@RequestMapping("/me/solarModel")
@Api(value = "DifferentSolarModelController", tags = "模型检验评估-不同太阳活动条件大气模型评估")
public class DifferentSolarModelController {

    @Resource
    private DifferentSolarModelService differentSolarModelService;
    //@PreAuthorize("@ss.hasPermi('me:differentAltitude:testAdd')")
    @ApiOperation(value = "太阳数据入库", notes = "太阳数据入库")
    @GetMapping("/testAdd")
    public AjaxResult testAdd(@ApiParam(value = "路径", name = "path", required = true)@RequestParam(value = "path") String path) {
        return differentSolarModelService.testAdd(path);
    }
    //@PreAuthorize("@ss.hasPermi('me:solarModel:getInitialData')")
    @ApiOperation(value = "初次进入太阳活动指数页面数据获取", notes = "初次进入太阳活动指数页面数据获取")
    @GetMapping("/getInitialData")
    public AjaxResult getInitialData() {
        return differentSolarModelService.getInitialData();
    }

    //@PreAuthorize("@ss.hasPermi('me:solarModel:getCalculateResult')")
    @ApiOperation(value = "获取计算评估结果", notes = "获取计算评估结果")
    @PostMapping("/getCalculateResult")
    public AjaxResult getCalculateResult(@RequestBody Map<String, Object> map) throws ProcessStopException {
        return differentSolarModelService.getCalculateResult(map);
    }
    //@PreAuthorize("@ss.hasPermi('me:spatialIndex:download')")
    @ApiOperation(value = "下载报告", notes = "下载报告")
    @PostMapping("/download")
    public AjaxResult download(@RequestBody Map<String, Object> map){
        return differentSolarModelService.download(map);
    }
    //@PreAuthorize("@ss.hasPermi('me:spatialIndex:subscribe')")
    @ApiOperation(value = "建立连接", notes = "建立连接")
    @GetMapping(path = "subscribe", produces = {MediaType.TEXT_EVENT_STREAM_VALUE})
    public SseEmitter push(String id, String flag) {
        return differentSolarModelService.push(id,flag);
    }
}
